<script type="text/javascript" src="includes/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="includes/javascript/tiny.js"></script>

<script type="text/javascript" src="jquery/jquery-latest.js"></script>
<script type="text/javascript" src="jquery/jquery.validate.js"></script>
<script type="text/javascript" src="includes/javascript/frmregister.js"></script>
<script src="includes/javascript/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="includes/javascript/jquery.validationEngine.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="utf-8" />
<link rel="stylesheet" href="css/template.css" type="text/css" media="screen" title="no title" charset="utf-8" />
		

<script>	
$(document).ready(function() {
	$("#addnews").validationEngine()
});
// JUST AN EXAMPLE OF CUSTOM VALIDATI0N FUNCTIONS : funcCall[validate2fields]
function validate2fields(){
	if($("#fname").val() =="" ||  $("#lname").val() == ""){
		return false;
	}else{
		return true;
	}
}
</script>
<script type="text/javascript">
$(document).ready(function()
{
$("#category").change(function()
{
var id=$(this).val();
var dataString = 'id='+ id;

$.ajax
({
type: "POST",
url: "ajax_subcat.php",
data: dataString,
cache: false,
success: function(html)
{
$("#subcategory").html(html);
} 
});

});
});
</script>

<?php	
						$sql = mysql_query("select * from news where news_id=".$_REQUEST['id']);       
						
						$row= mysql_fetch_array($sql);
						?>

<!--Add News-->
                        <form name="addnews" id="addnews" enctype="multipart/form-data" method="post" action="editnews_process.php">
                            
                            <table border="0" width="100%" cellspacing="0" cellpadding="2">						
                                <tr><td colspan="4" class="create">Edit NEWS</td></tr>
								<tr><td colspan="4" style="height:15px;"></td></tr>
                                <tr>
                                    <td width="150">Title :</td>
                                    <td><input  type="hidden" id="newsid" name="newsid" value="<?php echo $row['news_id']; ?>"><input  type="text" id="title" name="title" class="validate[required] text-input" value="<?php echo $row['title']; ?>"></td>                                    
                                </tr>
								
								<?php 
							$c=mysql_query("select * from categories as cat, news as n where cat.category_id=n.category_id and n.news_id=".$row['news_id']); 	
							$tt=mysql_fetch_array($c);
							$c_id=$tt['category_id'];
							$c_name=$tt['category'];

							?>
                                
                                <tr>
                                    <td>Categories:</td>
                                    <td><select name="category" id="category" class="validate[required]">
									<?php
									echo "<option value='".$c_id."' selected='selected'>".$c_name."</option>";
									
									$c1=mysql_query("select * from categories");
									while($r=mysql_fetch_array($c1))
									{
										if($r['category_id']!=$c_id)
										{
	 
									   echo "<option value='".$r['category_id']."'>".$r['category']."</option>";
									   }
									
									}

								  ?></select></td>
                                    
                                </tr>
								
							<?php 
							$s=mysql_query("select * from subcategories as s, news as n where s.subcategory_id=n.subcategory_id and n.news_id=".$row['news_id']); 	
							$sub=mysql_fetch_array($s);
							$s_id=$sub['subcategory_id'];
							$s_name=$sub['subcategory'];

							?>
                                <tr>
                                    <td>SubCategories:</td>
                                    <td><select name="subcategory" id="subcategory" class="validate[required]">
									<?php
									echo "<option value='".$s_id."' selected='selected'>".$s_name."</option>";
									
									$s1=mysql_query("select * from subcategories");
									while($r1=mysql_fetch_array($s1))
									{
										if($r1['subcategory_id']!=$s_id)
										{
	 
									    echo "<option value='".$r1['subcategory_id']."'>".$r1['subcategory']."</option>";
									   }
									
									}

								  ?></select></td>
                                    
                                </tr>                                  
                                <tr>
                                    <td colspan="2">Short News:</td>
                                    
                                </tr>				
                                 <tr>
                                    <td colspan="2"><textarea rows="10" cols="70" name="snews" id="snews"><?php echo $row['snews']; ?></textarea></td>
                                    
                                </tr>    
                                <tr>
                                    <td colspan="2">Description:</td>
                                    
                                </tr>				
                                 <tr>
                                    <td colspan="2"><textarea rows="10" cols="70" name="desc" id="desc"><?php echo $row['description']; ?></textarea></td>
                                </tr>          
								<tr><td colspan="2" style="height:10px;"></tr>
          
                                <tr><td colspan="2" style="height:10px;"></tr>						
                                <tr>
                                    <td colspan="3" align="center"><input type="submit" name="submit" value="Submit" onClick="return validate();" class="sub-butt"/></td>
                                </tr>
                            </table>
                        </form>
                        <!--End Add Products-->
                    </td>                    
                </tr>                
            </table>
        <!--end Products-->